home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 June: Reference Library / Dev.CD Jun 94.toast / Periodicals / develop / develop Issue 11 / develop 11 code / Async Sound Helper / SoundHelper / SoundHelper.h < prev   
Encoding:
Text File  |  1992-07-15  |  4.2 KB  |  99 lines  |  [TEXT/MPS ]

  1. //=======================================================================================
  2. //
  3. // SoundHelper.h - public header for the Asynchronous Sound Helper
  4. //
  5. // Written by Bryan K. Ressler (Beaker), 2/4/92
  6. //
  7. // Version 1.00, 2/4/92        Original version
  8. //         1.01, 2/20/92    Added SHGetState to fix handle semaphore problem
  9. //         1.02, 3/21/92    Make handle/error checks more explicit, modify
  10. //                             SHPlayStopByRec (to handle channels with no synthesizer)
  11. //         1.03, 4/4/92        Modifications per KO, RC, JR.  Public routines now pascal.
  12. //         1.04, 4/20/92    Reverted to SHPlayPause/SHPlayContinue structure.
  13. //
  14. //=======================================================================================
  15.  
  16. //=======================================================================================
  17. // Includes
  18. //=======================================================================================
  19. #include "Std.h"
  20.  
  21. //=======================================================================================
  22. // Enumerated types
  23. //=======================================================================================
  24. typedef enum {
  25.     shpError = -1,
  26.     shpFinished = 0,
  27.     shpPaused = 1,
  28.     shpPlaying = 2
  29. } SHPlayStat;
  30.  
  31. typedef enum {
  32.     shrError = -1,
  33.     shrFinished = 0,
  34.     shrPaused = 1,
  35.     shrRecording = 2
  36. } SHRecordStat;
  37.  
  38. //=======================================================================================
  39. // Sound Helper error codes
  40. //=======================================================================================
  41. #define kSHErrOutaChannels        1        // No more output records are available
  42. #define kSHErrBadRefNum            2        // Invalid reference number
  43. #define kSHErrNonAsychDevice    3        // Input device can't handle asynchronous input
  44. #define kSHErrNoRecording        4        // There's no recording to return
  45. #define kSHErrNotRecording        5        // Not allowed because we're not recording
  46. #define kSHErrAlreadyPaused        6        // Already paused
  47. #define kSHErrAlreadyContinued    7        // Already continued
  48.  
  49. //=======================================================================================
  50. // Structures
  51. //=======================================================================================
  52. typedef struct {
  53.     SHRecordStat    recordStatus;        // Current record status
  54.     unsigned long    totalRecordTime;    // Total (maximum) record time in ms
  55.     unsigned long    currentRecordTime;    // Current recorded time in ms
  56.     short            meterLevel;            // 0..255, the current input level
  57. } SHRecordStatusRec;
  58.  
  59. //=======================================================================================
  60. // Initialization, idle, and termination
  61. //=======================================================================================
  62. pascal OSErr SHInitSoundHelper(Boolean *attnFlag, short numChannels);
  63. pascal void SHIdle(void);
  64. pascal void SHKillSoundHelper(void);
  65.  
  66. //=======================================================================================
  67. // Easy sound output
  68. //=======================================================================================
  69. pascal OSErr SHPlayByID(short resID, long *refNum);
  70. pascal OSErr SHPlayByHandle(Handle sound, long *refNum);
  71.  
  72. pascal OSErr SHPlayStop(long refNum);
  73. pascal OSErr SHPlayStopAll(void);
  74.  
  75. //=======================================================================================
  76. // Advanced sound output
  77. //=======================================================================================
  78. pascal OSErr SHPlayPause(long refNum);
  79. pascal OSErr SHPlayContinue(long refNum);
  80.  
  81. pascal SHPlayStat SHPlayStatus(long refNum);
  82. pascal OSErr SHGetChannel(long refNum, SndChannelPtr *channel);
  83.  
  84. //=======================================================================================
  85. // Easy sound input
  86. //=======================================================================================
  87. pascal OSErr SHRecordStart(short maxK, OSType quality, Boolean *doneFlag);
  88. pascal OSErr SHGetRecordedSound(Handle *theSound);
  89.  
  90. pascal OSErr SHRecordStop(void);
  91.  
  92. //=======================================================================================
  93. // Advanced sound input
  94. //=======================================================================================
  95. pascal OSErr SHRecordPause(void);
  96. pascal OSErr SHRecordContinue(void);
  97.  
  98. pascal OSErr SHRecordStatus(SHRecordStatusRec *recordStatus);
  99.